package com.ss.jdk.lambda;

import com.ss.jdk.lambda.doman.Person;

import java.util.*;

/**
 * @Auther: ljy.s
 * @Date: 2022/9/10 - 09 - 10 - 2:39
 */
public class Demo04Lambda {
    // 这是一个main方法，是程序的入口：
    public static void main(String[] args) {
        List<Person> list = new ArrayList<>();
        list.add(new Person("周杰伦", 33, 175));
        list.add(new Person("刘德华", 43, 177));
        list.add(new Person("周星驰", 35, 176));
        list.add(new Person("郭富城", 34, 174));

        Collections.sort(list, new Comparator<Person>() {
            @Override
            public int compare(Person o1, Person o2) {
                return o1.getAge()-o2.getAge();
            }
        });
        for (Person person : list) {
            System.out.println(person);
        }

        System.out.println("-----------------------------");

        Collections.sort(list, (Person o1, Person o2) -> {
            return o1.getAge()-o2.getAge();
        });
        for (Person person : list) {
            System.out.println(person);
        }
    }
}
